home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / MATHS / ARCAUT / Automatons / Wire < prev   
Text File  |  1991-07-27  |  3KB  |  81 lines

  1. AUTOMATON*
  2.  
  3.   Wire_World
  4.  
  5.   This is a four state Moore neighbourhood automaton. It simulates the flow
  6.   of electrons around a circuit. Although it does not obey similar laws (such
  7.   as Kirchoff's) to real electrical current, memorys, clocks & logic gates
  8.   can all be built from basic components, thus a computer can be constructed
  9.   within the 'wire world' environment. The four states are background, wire,
  10.   electron head & electron tail. Background is inert; electron heads become
  11.   tails & tails become wire; wire will become electron head if it has one or
  12.   two electron head neighbours, otherwise it remains wire. This results in
  13.   electron head/tail pairs travelling in the direction of the head, along
  14.   stable wires, on an inert background. When executed, you are allowed to
  15.   design your own circuit, or load one in (press 'L'); disc space allowing,
  16.   two 128x128 screens are provided, called 'trans' & 'wheat'. Clicking select
  17.   draws wire from the current point to the pointer; adjust moves the current
  18.   point to the pointer & menu erases. The cursors place an electron at the
  19.   current point, while the cursors with right Ctrl place a 'diode' into the
  20.   circuit. When complete, press return to run the automaton.
  21.  
  22. INITIALISATION*
  23.  
  24.   10DEF PROCdo
  25.   20*SetEval wrap on
  26.   30*SetEval eh 22
  27.   40*SetEval et 214
  28.   50*SetEval back 0
  29.   60*SetEval wire 137
  30.   70ENDPROC
  31.  
  32. SCREEN*
  33.  
  34.   10DEF PROCdo
  35.   20LOCAL x%,y%,z%,c%,u%,v%,f$
  36.   30DIM buf% 256
  37.   40SYS "OS_ReadVarVal","wire",buf%,256:wire=!buf%
  38.   50SYS "OS_ReadVarVal","back",buf%,256:back=!buf%
  39.   60SYS "OS_ReadVarVal","eh",buf%,256:eh=!buf%
  40.   70SYS "OS_ReadVarVal","et",buf%,256:et=!buf%
  41.   80SYS "OS_ReadVarVal","sux",buf%,256:sux%=!buf%
  42.   90SYS "OS_ReadVarVal","suy",buf%,256:suy%=!buf%
  43.  100c%=FNacol(wire)
  44.  110PROCmouseon
  45.  120MOUSE TO 0,0:MOVE 0,0
  46.  130REPEAT MOUSE x%,y%,z%
  47.  140IF INKEY-87 PROCload:MOVE x%,y%
  48.  150CASE z% OF
  49.  160WHEN 4:c%=FNacol(wire):GCOL c% AND 63 TINT c%:DRAW x%,y%
  50.  170WHEN 2:c%=FNacol(back):GCOL c% AND 63 TINT c%:CIRCLE FILL x%,y%,12
  51.  180WHEN 1:MOVE x%,y%
  52.  190ENDCASE
  53.  200PROCcursors(u%,v%)
  54.  210IF u% OR v% THEN
  55.  220IF INKEY-8 THEN
  56.  230c%=FNacol(wire):GCOL c% AND 63 TINT c%
  57.  240DRAW BY -v%,u%:DRAW BY u%,v%:DRAW BY u%+v%,v%-u%
  58.  250DRAW BY v%-u%,-v%-u%:DRAW BY -u%,-v%:MOVE BY 2*u%-v%,2*v%+u%
  59.  260ELSE
  60.  270c%=FNacol(et):GCOL c% AND 63 TINT c%
  61.  280DRAW BY u%,v%
  62.  290c%=FNacol(eh):GCOL c% AND 63 TINT c%
  63.  300PLOT 9,u%,v%
  64.  310ENDIF
  65.  320REPEAT PROCcursors(u%,v%):UNTIL (u% OR v%)=0
  66.  330ENDIF
  67.  340UNTIL INKEY-74
  68.  350MOUSE OFF
  69.  360ENDPROC
  70.  
  71. CODE*
  72.  
  73. ( CELL <back> = IF (<back> ==)
  74.   CELL   <eh> = IF (  <et> ==)
  75.   CELL   <et> = IF (<wire> ==)
  76.   READ_NEIG
  77.   <eh> SCOUNT_NEIG DUP 1 = IF (  <eh> ==)
  78.                        2 = IF (  <eh> ==)
  79.                                <wire> ==  )
  80.  
  81. END*